<style>
    .salaydetail .prize {
        padding: 0 30px;
    }
</style>
<style scoped>
</style>

<template>
    <div class="salaydetail">
        <product-title></product-title>
        <div class="prize ">
            <div class="mb24">
                欢迎查看&nbsp;
                <span style="color:red;">{{name}}</span>&nbsp;
                <span style="color:red;">{{month}}</span>&nbsp;的辅导津贴基数详情
            </div>
            <Row class="mb24">
                <div class="table-theme highlight_table">
                    <Table :columns="columns" :data="tableList" size="large" stripe highlight-row border></Table>
                </div>
            </Row>
            <Row class="mb24">
                <div class="table-theme highlight_table">
                    <Table :columns="columns2" :data="tableList2" size="large" stripe highlight-row border></Table>
                </div>
            </Row>
            <div id="footer" style="padding:0 30px;">
                <Button id="back" @click="back()" shape="circle" style="border-radius: 30px !important;background:#77B4F5;color:white;font-size:14px;margin-top:25px;">返回</Button>
            </div>
        </div>
    </div>
</template>

<script>
    import productTitle from '../../components/productTitle'
    import {
        coach_detail
    } from '../../api/basic'
    import util from '../../libs/util.js';
    export default {
        data() {
            return {
                name: "",
                month: '',
                columns: [{
                        type: 'index',
                        title: '序号',
                        align: 'center',
                        width: '80'
                    },
                    {
                        title: '保单号',
                        key: 'policy_num',
                        align: 'center',
                    },
                    {
                        title: '险种名称',
                        key: 'pro_name',
                        align: 'center',
                    },
                    {
                        title: '营销员姓名',
                        key: 'emp_name',
                        align: 'center',
                    },
                    {
                        title: '钱数(元)',
                        key: 'money',
                        align: 'center',
                    },
                    {
                        title: '备注',
                        key: 'remark',
                        align: 'center',
                    },
                    {
                        title: '更新时间',
                        key: 'update_time',
                        align: 'center',
                    },
                ],
                tableList: [],
                columns2: [{
                        type: 'index',
                        title: '序号',
                        align: 'center',
                        width: '80'
                    },
                    {
                        title: '保单号',
                        key: 'policy_num',
                        align: 'center',
                    },
                    {
                        title: '险种名称',
                        key: 'pro_name',
                        align: 'center',
                    },
                    {
                        title: '营销员姓名',
                        key: 'emp_name',
                        align: 'center',
                    },
                    {
                        title: '钱数(元)',
                        key: 'money',
                        align: 'center',
                    },
                    {
                        title: '备注',
                        key: 'remark',
                        align: 'center',
                    },
                    {
                        title: '更新时间',
                        key: 'update_time',
                        align: 'center',
                    },
                ],
                tableList2: [],
            }
        },
        components: {
            productTitle
        },
        created() {
            this.name = this.$route.params.name;
            this.month = this.$route.params.month;
            this.getDetail();

        },
        methods: {
            //   点击返回
            back() {
                this.$router.back(-1)
            },
            getDetail() {
                var data = {
                    eid: this.$route.params.id,
                    month: this.$route.params.month,
                }
                new Promise((resolve, reject) => {
                    coach_detail(data).then(response => {
                        if (response.data.err == 0) {
                            this.tableList = response.data.data.list1;
                            for (var i in this.tableList) {
                                if (this.tableList[i].update_time) {
                                    let ds = this.tableList[i].update_time * 1000;
                                    let year = new Date(ds).getFullYear();
                                    let mon = new Date(ds).getMonth()+1;
                                    mon=mon<10?'0'+mon:mon;
                                    let da = new Date(ds).getDate();
                                    da=da<10?'0'+da:da;
                                    let dates = year + '-' + mon +'-' + da;
                                    this.tableList[i].update_time = dates
                                }
                            }
                            this.tableList2 = response.data.data.list2;
                            for (var k in this.tableList2) {
                                if (this.tableList2[k].update_time) {
                                    let dx = this.tableList2[k].update_time * 1000;
                                    let year2 = new Date(dx).getFullYear();
                                    let mon2 = new Date(dx).getMonth()+1;
                                    mon2=mon2<10?'0'+mon2:mon2;
                                    let da2 = new Date(dx).getDate();
                                    da2=da2<10?'0'+da2:da2;
                                    let date = year2 + '-' + mon2 +'-' + da2;
                                    this.tableList2[k].update_time = date
                                }
                            }
                        } else {
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
        }

    }
</script>